<?php
namespace App\Http\Controllers;

use Illuminate\Http\Request;
use App\Repos\BillboardRepo;
use App\Models\Category;
use App\Models\System;


class IndexController extends Controller
{
    public function index(Request $request)
    {
      	$cwhere = $where = [];
        if($request->category_id) {
            $cwhere['id'] = $where['category_id'] = $request->category_id;

        }
        $points = BillboardRepo::get($where);

        $cate   = Category::where($cwhere)->first();
        return view('map.index',compact('points','cate'));
    }

    public function traffic(Request $request)
    {
    	$where = [];
    	if($request->category_id) {
            $where['category_id'] = $request->category_id;
        }
        $points = BillboardRepo::get($where);

        $cate   = Category::where(['id'=>$request->category_id])->first();
        $system = System::first();
        return view('map.traffic',compact('points','cate','system'));
    } 

    
    
    
}
